package woa.graph;

import java.util.LinkedList;

/**
 * 图
 *
 * @author wangpeng
 * @date 2021/12/22
 */
public class Graph {

    /**
     * 顶点的个数
     */
    private int v;

    /**
     * 邻接表
     */
    private LinkedList<Integer>[] adj;

    public Graph(int v) {
        this.v = v;
        adj = new LinkedList[v];
        for (int i=0; i<v; ++i) {
            adj[i] = new LinkedList<>();
        }
    }

    public void addEdge(int s, int t) {
        // s先于t，边s->t
        adj[s].add(t);
    }
}
